let arr=[1,4,7,9,10]
let sum = 11

function check(arr,sum){
    for (let j = 0 ; j<arr.length ; j++){
        if(j==arr.length-1){
            return false
        }
        for(let k=j+1; k<arr.length ; k++){
            if(arr[j]+arr[k]==sum){
                return [j,k]
            }
        }
    }
}

function twoSum(arr,sum){
    let a= [];
   for(var i = 0,len=arr.length;i<len;i++){
       var tmp = sum - arr[i];
       if(a[tmp]!== undefined){
           return [a[tmp],i];
       }
       a[arr[i]]=i
   }
}

console.log(check(arr,sum))
console.log(twoSum(arr,sum))